package com.itheima.controller.backend;

import com.github.pagehelper.PageHelper;
import com.itheima.Service.CheckService;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.CheckItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("checkitem")
public class CheckController {
    @Autowired
    CheckService checkService;
    @PostMapping("/add")
    public Result add(@RequestBody CheckItem checkItem){
    checkService.add(checkItem);
    return new Result(true,"新增检查项成功",null);
    }
    @GetMapping("/delete")
    public Result delete(@RequestParam("id") Integer id){
        checkService.delete(id);
        return new Result(true,"删除检查项成功",null);
    }
    @PostMapping("/edit")
    public Result edit(@RequestBody CheckItem checkItem){
        checkService.edit(checkItem);
        return new Result(true,"编辑检查项成功",null);
    }
    @PostMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) throws IllegalAccessException {
    PageResult pageResult=checkService.findPage(queryPageBean);
    return pageResult;
    }
    @GetMapping("/findById")
    public Result findById(@RequestParam("id")Integer id){
        CheckItem checkItem=checkService.findById(id);
        return new Result(true,"查询成功",checkItem);
    }
}
